<template>
  <div class="head-container" ref="headBox">
    <div class="header">
      <div class="head-msg">
        <span class="msg-item">
          <img
            src="http://res0.chenxin99.com/cxbaomu/statics/images/mum/head_05.png"
            alt=""
            width="20px"
            height="19px"
          />
          风险把控
        </span>
        <span class="msg-item">
          <img
            src="http://res0.chenxin99.com/cxbaomu/statics/images/mum/head_07.png"
            alt=""
            width="20px"
            height="19px"
          />
          严格筛选
        </span>
        <span class="msg-item">
          <img
            src="http://res0.chenxin99.com/cxbaomu/statics/images/mum/head_09.png"
            alt=""
            width="20px"
            height="19px"
          />
          百万保险
        </span>
        <span class="msg-item">
          <img
            src="http://res0.chenxin99.com/cxbaomu/statics/images/mum/head_11.png"
            alt=""
            width="20px"
            height="19px"
          />
          试工满意再签合同
        </span>
        <span class="msg-item" style="">
          <img
            src="../imgs/weibo.png"
            alt=""
            width="20px"
            style="vertical-align: -3px"
          />
          <div class="qr">
            <img src="http://res0.chenxin99.com/images/weibo_qiye.png" alt="" />
          </div>
        </span>
        <span class="msg-item">
          <img
            src="../imgs/微信.png"
            alt=""
            width="25px"
            style="vertical-align: -10px"
          />
          <div class="qr">
            <img src="http://res0.chenxin99.com/images/weibo_qiye.png" alt="" />
          </div>
        </span>
        <span
          style="
            color: #f3212d;
            font-size: 15px;
            font-weight: 600;
            vertical-align: -1.5px;
          "
          class="msg-item"
        >
          <img src="../imgs/电话.png" alt="" width="20px" /> 13062621097 &nbsp;
          13062621096
        </span>
      </div>
      <div :class="{ nav: true, nav_fixed: isfixed }">
        <div class="logo">
          <img
            src="http://res0.chenxin99.com/images/logo.png"
            alt=""
            width="180px"
            @click="tp('/')"
          />
        </div>
        <ul class="nav-list">
          <li v-for="(item, i) in navdata" :key="i">
            <a
              @click="change(i)"
              :class="{ active: act[i].active }"
              v-if="i == 0"
              >{{ item }}</a
            >
            <a
              @click="change(i)"
              :class="{ active: act[i].active }"
              v-if="i == 1"
              >{{ item }}</a
            >
            <a
              @click="change(i)"
              :class="{ active: act[i].active }"
              v-if="i == 2"
              >{{ item }}</a
            >
            <a
              @click="change(i)"
              :class="{ active: act[i].active }"
              v-if="i == 3"
              >{{ item }}</a
            >
          </li>
          <li>
            <a>老人陪护</a>
          </li>
          <li>
            <a>钟点工</a>
          </li>
          <li>
            <a>在线选人</a>
          </li>
          <li>
            <a>服务价格表</a>
          </li>
          <li>
            <a>服务项目</a>
          </li>
          <li>
            <a>品牌加盟</a>
          </li>
          <li>
            <a>企业服务</a>
          </li>
          <li>
            <a>招聘找工作</a>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script scoped>
export default {
  data() {
    return {
      act: [
        { active: true },
        { active: false },
        { active: false },
        { active: false },
      ],
      navdata: ["首页", "月嫂", "保洁", "家政"],
      isfixed: false,
    };
  },
  methods: {
    tp(item){
      this.$router.push(item)
    },
    change(i) {
      
      if (i == 0) {
        this.$router.push("/");
      }else if (i == 1) {
        this.$router.push("/yuesao");
      }else if(i == 2){
        this.$router.push("/baojie");
      }else if(i == 3){
        this.$router.push("/jiazhen");
      }
    },
    scroll() {
      // let t = window.scrollTop
      console.log(123);
    },
  },
  mounted() {
    this.act.forEach((item) => {
      item.active = false;
    });
    if(window.location.href.indexOf("yuesao")!=-1){
      this.act[1].active = true;
    }else if(window.location.href.indexOf("baojie")!=-1){
      this.act[2].active = true;
    }else if(window.location.href.indexOf("jiazhen")!=-1){
      this.act[3].active = true;
    }else{
      this.act[0].active = true;
    }
  },
};
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
  text-decoration: none;
}
.logo{
  cursor: pointer;
}
.head-container {
  width: 100%;
  position: relative;
  z-index: 3;
}
.head-msg {
  height: 36px;
  line-height: 28px;
  text-align: right;
  font-size: 12px;
  color: #939393;
  background: #f5f5f5;
  padding-right: 50px;
}
.head-msg .msg-item {
  display: inline-block;
  padding: 0 10px;
  margin-top: 2px;
  position: relative;
  cursor: pointer;
}
.head-msg .msg-item img {
  vertical-align: -5px;
  margin-right: 5px;
}
.head-msg .msg-item .qr {
  position: absolute;
  top: 32px;
  left: -22px;
}
.qr img {
  width: 0;
  height: 0;
  transition: 0.3s;
}
.msg-item:hover .qr img {
  width: 100px;
  height: 100px;
}
.header .nav {
  display: flex;
  justify-content: space-between;
  padding: 0 45px;
  padding-bottom: 5px;
  padding-top: 20px;
  border-bottom: 2px solid #f30213;
  background: #fff;
}
.nav_fixed {
  position: fixed;
  top: 0;
}
.nav-list {
  display: flex;
  list-style: none;
  align-items: center;
  margin-right: 40px;
}
.nav-list li a {
  padding-left: 15px;
  padding-right: 15px;
  font-size: 18px;
  color: #000;
  cursor: pointer;
}
.nav-list li a:hover {
  color: #f30213;
}
.nav-list li a.active {
  font-weight: bold;
  color: #f30213;
}
</style>